//
//  search_seglastItem.m
//  SoundPill
//
//  Created by 宋鹏鹏 on 15/4/7.
//  Copyright (c) 2015年 宋旭东. All rights reserved.
//

#import "search_seglastItem.h"
#define kDeviceHeight [UIScreen mainScreen].bounds.size.height
#define kDeviceWidth  [UIScreen mainScreen].bounds.size.width

#define kTitleScale 0.7
// 设置宽高
#define kMenuItemW kDeviceWidth/3
#define kMenuItemH 45
@implementation search_seglastItem

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
        [self setTitleColor:[UIColor blackColor] forState:UIControlStateSelected];
        
        self.imageView.contentMode = UIViewContentModeScaleAspectFit;
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
        self.titleLabel.font = [UIFont systemFontOfSize:16];
        
        // 3.上边的分割线
        UIImage *upImg = [UIImage imageNamed:@"gray_line"];
        UIImageView *updivider = [[UIImageView alloc] initWithImage:upImg];
        updivider.bounds = CGRectMake(0, 0, kMenuItemW, 0.8);
        updivider.center = CGPointMake(kMenuItemW/2, 0.4);
        [self addSubview:updivider];
        // 3.下边的分割线
        UIImage *downImg = [UIImage imageNamed:@"gray_line"];
        UIImageView *downDivider = [[UIImageView alloc] initWithImage:downImg];
        downDivider.bounds = CGRectMake(0,0, kMenuItemW, 0.8 );
        downDivider.center = CGPointMake(kMenuItemW/2, kMenuItemH-0.4);
        [self addSubview:downDivider];
        
        
        self.backgroundColor = [UIColor whiteColor];
        
        
    }
    return self;
}


- (void)setFrame:(CGRect)frame
{
    frame.size = CGSizeMake(kMenuItemW, kMenuItemH);
    [super setFrame:frame];
}

- (CGRect)titleRectForContentRect:(CGRect)contentRect
{
    CGFloat h = contentRect.size.height*0.6;
    CGFloat w = contentRect.size.width*0.6;
    return CGRectMake(contentRect.size.width*0.2, contentRect.size.height*0.2, w, h);
}

- (CGRect)imageRectForContentRect:(CGRect)contentRect
{
    CGFloat h = 1;
    CGFloat w = contentRect.size.width*0.6;
    
    return CGRectMake(contentRect.size.width*0.2,contentRect.size.height, w, h);
}

@end
